@extends('layouts.tankuang')

@section('content')
    <form name="add_form" id="add_form" action="{{url('admin/units/add_baowei',$id)}}" method="post" enctype="multipart/form-data">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div>
            <h2 class="text-center mg_b36 mg_t25">应急预案登记表</h2>
            <table class="table-form table-border w mg-auto">
                <tr>
                    <td align="center" class="font-bd">编制单位</td>
                    <td><input type="text" class="form-input" value="{{$re->unit_name}}" name="unit_name"></td>
                    <td align="center" class="font-bd">应急预案主题</td>
                    <td><input type="text" class="form-input easyui-validatebox" value="{{$re->name}}" name="name" data-options="required:true,missingMessage:'应急预案主题不能为空',validateOnCreate:false,validateOnBlur:true"></td>
                </tr>
                <tr>
                    <td align="center" class="font-bd">编制人</td>
                    <td><input type="text" class="form-input easyui-validatebox" value="{{$re->bianzhiren}}" name="bianzhiren" data-options="required:true,missingMessage:'编制人不能为空',validateOnCreate:false,validateOnBlur:true"></td>
                    <td align="center" class="font-bd">编制时间</td>
                    <td><input class="easyui-datebox w153 easyui-validatebox" value="{{$re->bianzhi_time}}" name="bianzhi_time" data-options="required:true,missingMessage:'编制时间不能为空',validateOnCreate:false,validateOnBlur:true"></td>
                </tr>
                <tr>
                    <td align="center" class="font-bd">预案内容</td>
                    <td colspan="3">
                        <textarea class="textarea easyui-validatebox" name="content" rows="20" data-options="required:true,missingMessage:'预案内容不能为空',validateOnCreate:false,validateOnBlur:true">{{$re->content}}</textarea>
                    </td>
                </tr>
                <tr>
                    <td align="center" class="font-bd">应急预案</td>
                    <td colspan="3">
                        @if($re->yuan != '')<a href="{{ URL::asset('/') }}{{$re->yuan}}" style="color: red">下载预案</a> @endif
                        <input type="file" value="" name="yuan" class="w178" style="float: left">
                    </td>
                </tr>
            </table>
            {{--<div class="w1000 wbt mg_t25 mg_b18">
                <span class="font-bd">填报单位：</span>
                <input type="text" class="w250 input_bottom dsp" name="">
                <span class="itv"></span>
                <span class="font-bd">填报人：</span>
                <input type="text" class="w250 input_bottom dsp">
            </div>--}}
            <div class="w wbt mg_t25 text-center">
                <button id="go" type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-save'">确定</button>
                <button type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-no'" onclick="$('#tk').window('close')">关闭</button>
            </div>
        </div>
    </form>

    <script>
        $('#go').click(function (){
        	if(!$("#add_form").form('validate')){
				return false;
				}
            var formData = new FormData($("#add_form")[0]);
            $.ajax({
                type: "POST",
                url: "{{url('admin/units/edit_tfsj',$id)}}",
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                /*error: function(data) {
                    $.messager.alert('信息提示',data.msg,'info');
                },*/
                success: function(data) {
                    $.messager.alert('信息提示',data.msg,'info');
                    $('#tk').dialog('close');
                    $('.pagination-load').click();
                },
                error: function(msg) {
                    var json=JSON.parse(msg.responseText);
                    $.each(json, function(index, value) {
                        $.messager.alert('信息提示',value,'info');die;
                    });
                },
            });
        });
    </script>
@stop